package com.interagriculture.controller;

import com.interagriculture.annotation.AdminVerify;
import com.interagriculture.common.Result;
import com.interagriculture.entity.TeacherInfo;
import com.interagriculture.service.TeacherInfoService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @author 11 2024/11/13
 */
@RestController
@RequestMapping("/adminTeacher")
public class AdminTeacherController {

    @Resource
    private TeacherInfoService teacherInfoService;

    /**
     * 添加或修改老师信息
     * @param teacherInfo
     * @return
     */
    @PostMapping("/saveOrUpdateInfo")
    @AdminVerify
    public Result saveOrUpdateInfo(@RequestBody TeacherInfo teacherInfo) {
        teacherInfoService.saveOrUpdateInfo(teacherInfo);
        return Result.ok();
    }

    /**
     * 删除老师信息
     * @param teacherId
     * @return
     */
    @DeleteMapping("/delete")
    @AdminVerify
    public Result deleteById(@RequestParam @NotNull Integer teacherId) {
        teacherInfoService.deleteById(teacherId);
        return Result.ok();
    }
    @GetMapping("/{id}")
    @AdminVerify
    public Result<TeacherInfo> getById(@PathVariable @NotNull Integer id) {
        return Result.ok(teacherInfoService.queryById(id));
    }
}
